package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.AddCsStatusLogBean;
import com.ymatou.iapi.csim.parameter.UpdateCsStatusLogEndTimeBean;
import com.ymatou.iapi.csim.service.AddCsStatusLogCall;
import com.ymatou.iapi.csim.service.UpdateCsStatusLogEndTimeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_csstatuslog;
import com.ymttest.database.sqlwapper.CSIM.ymt_cssessionWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_csstatuslogWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_onlinecsWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_queuesessionWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*更新客服状态变更结束时间
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UpdateCsStatusLogEndTime{
	private static UpdateCsStatusLogEndTimeBean updatecsstatuslogendtimeBean;
	private static UpdateCsStatusLogEndTimeCall updatecsstatuslogendtimeCall;
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private String csName=EnvSetup.getData("csName").toString();
	private static ymt_csstatuslogWapper csstatislogWapper=new ymt_csstatuslogWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新客服状态变更结束时间");
	}

	@Before
	public void caseUp() {
		updatecsstatuslogendtimeBean=new UpdateCsStatusLogEndTimeBean();
		updatecsstatuslogendtimeCall=new UpdateCsStatusLogEndTimeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(updatecsstatuslogendtimeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCsStatusLogEndTime_1() {
		Logger.start(true,"更新客服状态变更结束时间(记录CsStatusLog表的EndTime)");
		try {
			AddCsStatusLogBean bean=new AddCsStatusLogBean();
			AddCsStatusLogCall call=new AddCsStatusLogCall();
			ymt_csstatuslog log=csstatislogWapper.selectByCSId(csId).size()>0?csstatislogWapper.selectByCSId(csId).get(0):null;
			if(log==null)
			{
				bean.setCsId(csId);
				bean.setCsName(csName);
				bean.setRemark("测试新增客服状态变更记录_"+TestDataManager.getRandomIntNum(5));
				bean.setStatusType(0);//0:上线 1:离线
				call.setData(bean);
				call.callService();	
			}
			
			updatecsstatuslogendtimeBean.setCsId(csId);
			updatecsstatuslogendtimeCall.setData(updatecsstatuslogendtimeBean);
			updatecsstatuslogendtimeCall.callService();		
			
		//	ymt_csstatuslog csstatuslog=csstatislogWapper.selectByPrimaryKey(call.getResult().getString("StatusLogId"));
			
		//	Logger.verifyNotNull(csstatuslog.getEndTime(), "验证EndTime更新成，不为空");
			Logger.verifyEquals("0", updatecsstatuslogendtimeCall.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, updatecsstatuslogendtimeCall.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", updatecsstatuslogendtimeCall.getStatus(), "验证Status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}